package com.cms.plugins.plugins_market;


import com.cms.common.hook.target.BootstrapTarget;
import com.cms.common.hook.target.Hook;
import com.cms.common.hook.vo.HookParams;
import com.cms.common.hook.vo.HookResult;
import com.cms.common.model.entity.Plugin;
import com.cms.common.model.services.PluginBootstrap;
import com.cms.common.model.vo.Menu;
import com.gitee.starblues.bootstrap.PluginContextHolder;
import com.gitee.starblues.core.descriptor.InsidePluginDescriptor;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@BootstrapTarget
@Component
public class BootstrapPlugin implements PluginBootstrap {




    @Hook(hook_key = "admin.menus")
    public HookResult addMenu(HookParams params) {

        List<Menu> menus = (List<Menu>) params.getRequestParams().get("menuList");

        List<Menu> devChildrenList = new ArrayList<Menu>();
        devChildrenList.add(Menu.createMenu("我的插件", "", "/plugins/plugins-feature-plugin-market/admin/markets", ""));
        devChildrenList.add(Menu.createMenu("插件订单", "", "/plugins/plugins-feature-plugin-market/admin/orders", ""));
        List<String> pluginPrefixes = new ArrayList<String>();
        pluginPrefixes.add("markets");
        pluginPrefixes.add("orders");
        menus.add(Menu.createMenu("开发者中心", "el-icon-orange", "/plugins/plugins-feature-plugin-market/admin/market/index",devChildrenList, pluginPrefixes));

        params.getRequestParams().put("menuList", menus);
        return new HookResult();
    }



    public Plugin config() {
        Plugin plugins = new Plugin();
        InsidePluginDescriptor descriptor = PluginContextHolder.getPluginDescriptor();
        plugins.setPluginId(descriptor.getPluginId());
        plugins.setName("Plugins Market");
        plugins.setLogo("");
        plugins.setDescription("插件市场");

        return plugins;
    }

}
